package com.example.xwcommon.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.xwcommon.entity.Weibo;
import com.example.xwcommon.service.fallback.FallBackWeiboServiceImpl;
import com.example.xwcommon.vo.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(value = "xw-weibo",fallback = FallBackWeiboServiceImpl.class   )
public interface WeiboService {
    //添加微博
    @RequestMapping("/weibo/addWeibo")
    Response<Weibo> addWeibo(@RequestParam("userName") String userName,@RequestParam("title") String title,@RequestParam("content") String content,@RequestParam("img") String img);

    //根据微博id查询微博
    @RequestMapping("/weibo/getWeiboById")
    Response<Weibo> getWeiboById(@RequestParam("weiboId") Integer weiboId);

    //根据用户名分页查询微博
    @RequestMapping("/weibo/getWeiboListByLoginName")
    Response<Page<Weibo>> getWeiboListByLoginName(@RequestParam("pageNum")Integer pageNum,@RequestParam("pageSize") Integer pageSize
            ,@RequestParam("loginName") String loginName,@RequestParam("state") Integer state);

    //根据微博状态查询微博
    @RequestMapping("/weibo/getWeiboListByState")
    Response<List<Weibo>> getWeiboListByState(@RequestParam("state") Integer state);

    //根据内容分页查询微博
    @RequestMapping("/weibo/list")
    Response<Page<Weibo>> list(@RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize") Integer pageSize
                                , @RequestParam("findtxt") String findtxt, @RequestParam("state") Integer state);

    //更新微博状态
    @PostMapping("/weibo/updateState")
    Response<Weibo> updateState(@RequestParam("weiboId") Integer weiboId,@RequestParam("state") Integer state);

    //更新阅读数
    @PostMapping("/weibo/updateReadCount")
    Response<Weibo> updateReadCount(@RequestParam("weiboId") Integer weiboId);

    //根据用户名查询微博总数
    @RequestMapping("/weibo/getWeiboCountByLoginName")
    Response<Integer> getWeiboCountByLoginName(@RequestParam("loginName") String loginName,@RequestParam("state") Integer state);

    //删除微博
    @PostMapping("/weibo/deleteWeibo")
    Response<Weibo> deleteWeibo(@RequestParam("weiboId") Integer weiboId);
}
